package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/product")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/save.do")
    public void saveUser(User user){
        System.out.println("进入存储");
        System.out.println(user);
        userService.saveUser(user);
        System.out.println(user);
        System.out.println("存储成功");
    }

    @RequestMapping("/findAll.do")
    public Model findAll(Model model){
        List<User> userList = userService.findAll();
        model.addAttribute("userList",userList);
        return model;
    }





}
